package com.gopher.gopherbeasts;

import com.badlogic.gdx.graphics.g2d.TextureRegion;

public abstract class Entity {

	public float x = 0f;
	public float y = 0f;
	public float w = 0f;
	public float h = 0f;

	public float velx = 0f;
	public float vely = 0f;
	public float accx = 0f;
	public float accy = 0f;

	public float ox = 0f;
	public float oy = 0f;
	public float maxSpeed = 8f;
	public float terminal = 50f;
	public float accelRate = 8f;

	public boolean alive = true;
	public boolean resting = true;
	public boolean collidesWithMap = true;

	public TextureRegion currentFrame;

	public Entity(float x, float y, float w, float h, TextureRegion texture) {
		this.x = x;
		this.y = y;
		this.w = w;
		this.h = h;

		currentFrame = texture;
	}

	public void move() {
		ox = x;
		oy = y;

		velx += accx;
		vely += accy;

		velx = Mth.clamp(velx, maxSpeed);
		//vely = Mth.clamp(vely, terminal);

		x += velx;
		y += vely;
	}

	public abstract void update();

	public abstract void render();

	public boolean collidesWith(Entity e) {
		if (x <= e.x + e.w && x + w >= e.x && y + h >= e.y && y <= e.y + e.h) {
			return true;
		} else {
			return false;
		}

		// return bounds.overlaps(e.bounds);
	}

	public abstract void collidedWith(Entity other);

	public boolean isAlive() {
		return alive;
	}

	public boolean collidesWithMap() {
		return collidesWithMap;
	}
}
